package com.bysj.controller;

import com.bysj.entity.GoodsReply;
import com.bysj.service.GoodsReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("goodsReply")
public class GoodsReplyController {
    @Autowired
    GoodsReplyService goodsReplyService;
    //添加商品评论
    @ResponseBody
    @RequestMapping("/addGoodsReply")
    public String addGoodsReply(@RequestBody GoodsReply goodsReply){
        goodsReplyService.addGoodsReply(goodsReply);
        return "sucess";

    }
    //获取当前商品所有评论
    @RequestMapping("/getGoodsReplyById")
    public List<GoodsReply> getGoodsReplyById(Integer id){
        return goodsReplyService.getGoodsReplyById(id);
    }

    //根据id删除评论
    @RequestMapping("/deleteReplyById")
    public String deleteReplyById(Integer id){
        goodsReplyService.deleteReplyById(id);
        return "success";
    }

}
